﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace agile_tool.userControl
{
    /// <summary>
    /// Interaction logic for timeAssignmentPage.xaml
    /// </summary>
    public partial class timeAssignmentPage : UserControl
    {
        public int taskId;
        public timeAssignmentPage()
        {
            InitializeComponent();

        }

        public bool checkTheTimes()
        {
            int temp = 10000;
            for (int i = 1; i < cbTaskTimes.Items.Count; i++)
            {
                int max = int.Parse(((timeAssignmentItem)cbTaskTimes.Items[i]).tbRemainng.Text);
                if (temp >= max)
                    temp = max;
                else
                    return false;
            }
            return true;
        }

        public bool fixTheTimes()
        {
            int max = int.Parse(((timeAssignmentItem)cbTaskTimes.Items[1]).tbRemainng.Text);
            for (int i = 1; i < cbTaskTimes.Items.Count; i++)
            {
                int temp = int.Parse(((timeAssignmentItem)cbTaskTimes.Items[i]).tbRemainng.Text);
                if (temp >= max)
                {
                    temp = max;
                    ((timeAssignmentItem)cbTaskTimes.Items[i]).tbRemainng.Text = temp.ToString();
                }
                else { max = temp; }
            }
            return true;
        }
    }
}
